<template>
  <div>
    <el-table v-loading="loading" :data="noticeList">
      <el-table-column label="序号" align="center" prop="order" width="50" />
      <!-- <el-table-column label="图片" align="center" min-width="120">
        <template slot-scope="scope">
          <el-image fit="cover" style="width:100px;height:100px" :src="scope.row.image"></el-image>
        </template>
      </el-table-column> -->
      <el-table-column label="申请单号" align="center" prop="noticeType" min-width="150">
        <template slot-scope="scope">
          <el-link @click="handledetailed(scope.row)" type="primary">{{ scope.row.disposalNum || '-' }}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="申请时间" align="center" min-width="150">
        <template slot-scope="scope">
          {{ scope.row.applicationTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="申请人" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.applicantName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="涉及设备" align="center" min-width="120" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.equipmentNames || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="变卖原因" align="center" min-width="120" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.reason || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="审核状态" align="center" min-width="120">
        <template slot-scope="scope">
          <dict-tag :options="statusAllocation" :value="scope.row.status" />
        </template>
      </el-table-column>
      <el-table-column label="审核结束时间" align="center" min-width="150">
        <template slot-scope="scope">
          {{ scope.row.auditEndTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="创建部门" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.deptName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="240" fixed="right">
        <template slot-scope="scope">
          <div align="center">
            <el-button v-hasPermi="['manage_resell_process']" size="small" type="primary" icon="el-icon-view"
              @click="handleSelect(scope.row)">审核流程</el-button>
            <el-button v-hasPermi="['manage_resell_again']" :disabled="!(scope.row.status === '2')"
              icon="el-icon-refresh" size="small" type="warning" @click="handleDelete(scope.row)">重新申请
            </el-button>
          </div>

        </template>
      </el-table-column>
    </el-table>
    <div class="card-div">
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
    <!-- 查看详情 -->
    <template v-if="open">
      <CationChildren :rowObj="rowObj"></CationChildren>
    </template>
    <!-- 查看审核流程 -->
    <template v-if="opendetailed">
      <ReconsiDeration :rowObj="detailedObj"></ReconsiDeration>
    </template>
    <!-- 重新申请 -->
    <template v-if="openadd">
      <AddAllocation :title="title" :rowObj="rowadd" @handleUpdate="handleUpdate"></AddAllocation>
    </template>
  </div>
</template>

<script>
// import { getbaselist, putchangeStatus } from "@/api/equipment/equipment.js";
import { getsaleList, postReapplySale } from "@/api/management/management.js";
import { getuntreatedcount } from '@/api/mianBody/index.js'

export default {
  // dicts: ['sys_notice_status', 'sys_notice_type'],
  components: {
    CationChildren: () => import('../form/cationChildren.vue'),//详情
    ReconsiDeration: () => import('../form/reconsideration.vue'),//审核流程
    AddAllocation: () => import('../form/addAllocation.vue')

  },
  data () {
    return {
      // 遮罩层
      loading: true,
      opendetailed: false,
      detailedObj: {},
      openadd: false,
      rowadd: {},
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      dictdatalist: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 弹出层表格数据
      noticeList: [],
      rowObj: {},
      // 弹出层标题
      title: "修改设备基值",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderByColumn: 'disposalId',
        isAsc: 'desc'//倒叙
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        noticeTitle: [
          { required: true, message: "公告标题不能为空", trigger: "blur" }
        ],
        noticeType: [
          { required: true, message: "公告类型不能为空", trigger: "change" }
        ]
      }
    };
  },
  created () {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    async getList (value) {
      this.loading = true;
      let obj = value || {}
      let params = {
        ...this.queryParams,
        ...obj,
        'params[equipmentName]': obj.equipmentName//设备名称
      }
      getsaleList(params).then(response => {
        this.noticeList = response.data && response.data.map((item, index) => {
          return {
            ...item,
            order: index + 1
          }
        });
        this.total = response.total;
        this.loading = false;
        getuntreatedcount().then(res => {
          this.$store.commit('SET_FEATUREMESSAGE', res.data)
        })
      });
    },
    // 打开详细弹窗
    handledetailed (row) {
      this.rowObj = row
      this.open = true
      // this.$parent.$parent.$parent.$parent.tabIndex = true
      // this.$parent.$parent.$parent.$parent.activeName = '3'
      // this.$parent.$parent.$parent.$parent.rowObj = row
    },
    /** 修改按钮操作 */
    handleSelect (row) {
      this.detailedObj = row
      this.opendetailed = true
    },
    // 多选框选中数据
    handleSelectionChange (selection) {
      this.ids = selection.map(item => item.noticeId)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    handleUpdate () {
      this.openadd = false
      this.getList()
    },
    /** 启用禁用按钮操作 */
    handleDelete (row) {
      this.openadd = true
      this.rowadd = row
      this.title = '申请变卖(重新申请)'
      // this.$confirm(`是否确认发起重新申请`, '提示', {
      //   confirmButtonText: '确定',
      //   cancelButtonText: '取消',
      //   type: 'warning'
      // }).then(() => {
      //   this.loading = true;
      //   let params = row.disposalId
      //   postReapplySale(params).then(res => {
      //     if (res.code === 200) {
      //       this.$message.success(res.msg)
      //       this.getList()
      //     }
      //     this.loading = false;
      //   }).catch(() => { this.loading = false; });
      // })
    }
  },
  filters: {
  }
};
</script>
<style lang="scss" scoped>
.red {
  color: red;
}
</style>